package com.xxd.dfs.common.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author: XiaoDong.Xie
 * @create: 2020-08-14 11:34
 * @description: 读取配置文件工具类
 */
public class PropertyUtil {

    /**
     * 配置文件
     */
    private static Properties properties = new Properties();

    /**
     * 读取 properties 测试项目配置文件
     *
     * @param propertiesPath 配置文件路径
     * @return Properties
     * @throws IOException IOException
     */
    public static Properties loadProperties(String propertiesPath){
        InputStream inputStream = ClassLoader.getSystemResourceAsStream(propertiesPath);
        try {
            properties.load(inputStream);
        } catch (Exception e) {

        }
        return properties;
    }

    /**
     * 依据键名获取配置文件中的键值
     *
     * @param key 键名
     * @return 键值
     */
    public static String getProperty(String key) {
        return properties.getProperty(key);
    }
}
